home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / intmail2 / rvclient.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-07-26  |  1.9 KB  |  81 lines

  1. {
  2. This is a client application, which works with
  3. RcServer.dpr.  First, recompile the RcServer.dpr and
  4. leave it running.  Then run this applicaiton, enter
  5. any string in the 'String to Send' box, and click
  6. Send button. The server should reverce the
  7. string and return it back.
  8. }
  9. unit RvClientMain;
  10.  
  11. interface
  12.  
  13. uses
  14.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  15.   StdCtrls, Mssocket, ComCtrls;
  16.  
  17. type
  18.   TClientForm = class(TForm)
  19.     Label1: TLabel;
  20.     Label2: TLabel;
  21.     SendButton: TButton;
  22.     CancelButton: TButton;
  23.     Label3: TLabel;
  24.     ResultLabel: TLabel;
  25.     ServerEdit: TEdit;
  26.     DataEdit: TEdit;
  27.     StatusBar: TStatusBar;
  28.     msClientSocket1: TmsClientSocket;
  29.     procedure SendButtonClick(Sender: TObject);
  30.     procedure msClientSocket1Connecting(Sender: TObject);
  31.     procedure msClientSocket1Connected(Sender: TObject);
  32.     procedure msClientSocket1Disconnected(Sender: TObject);
  33.   private
  34.     { Private declarations }
  35.   public
  36.     { Public declarations }
  37.   end;
  38.  
  39. var
  40.   ClientForm: TClientForm;
  41.  
  42. implementation
  43.  
  44. {$R *.DFM}
  45.  
  46. procedure TClientForm.SendButtonClick(Sender: TObject);
  47. begin
  48.   SendButton.Enabled:=false;
  49.   CancelButton.Enabled:=true;
  50.   try
  51.     msClientSocket1.Host:=ServerEdit.Text;
  52.     msClientSocket1.Connect;
  53.     try
  54.       msClientSocket1.SendLine(DataEdit.Text);
  55.       ResultLabel.Caption:=msClientSocket1.RecvLine;
  56.     finally
  57.       msClientSocket1.Disconnect;
  58.     end;
  59.   finally
  60.     SendButton.Enabled:=true;
  61.     CancelButton.Enabled:=false;
  62.   end;
  63. end;
  64.  
  65. procedure TClientForm.msClientSocket1Connecting(Sender: TObject);
  66. begin
  67.   StatusBar.SimpleText:='Connecting to '+msClientSocket1.Host;
  68. end;
  69.  
  70. procedure TClientForm.msClientSocket1Connected(Sender: TObject);
  71. begin
  72.   StatusBar.SimpleText:='Connected';
  73. end;
  74.  
  75. procedure TClientForm.msClientSocket1Disconnected(Sender: TObject);
  76. begin
  77.   StatusBar.SimpleText:='Disconnected';
  78. end;
  79.  
  80. end.
  81.